package cn.online.taxi.common.test;

public class Format {

    private double sqrt(int num, double low, double high, double range) {
        double mid = (low + high) / 2f;
        if (num - mid * mid < 0 ) {
            return sqrt(num, low,(mid + high)/2f,range);
        } else {
            if (num - mid * mid > range){
                return sqrt(num,(low + mid)/2f,high,range);
            }
            String str = String.format("%.6f",mid);
            return Double.parseDouble(str);
        }
    }

    public static void main(String[] args) {
        System.out.println(new Format().sqrt(3, 1, 4, 0.000001));
    }

}
